package org.edu.prj.langton.lefebvre;

import java.util.Timer;
import java.util.TimerTask;

import org.edu.prj.langton.lefebvre.impl.Fourmi;
import org.edu.prj.langton.lefebvre.impl.Terrain;
import org.edu.prj.langton.lefebvre.impl.Fourmi.Direction;


/**
 * 
 * @author loic lefebvre
 * @version 1.0, 24/06/2010
 */
public class LangtonMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//variables to init 
		int matrix_height = 100;
		int matrix_width = 100;
		int start_height = 50;
		int start_width = 50;
		int window_height=4;
		int window_width=5;

		/** build fourmi */
		final Fourmi myFourmi = new Fourmi("Loic", Direction.NORD);
		
		myFourmi.initialise(matrix_width, matrix_height);
		myFourmi.startAt(start_width, start_height);
//		System.out.println("INIT FOURMI");
//		System.out.println(myFourmi);

		/** build terrain */
		final Terrain terrain = new Terrain();
		terrain.setWidthWindow(window_width);
		terrain.setHeightWindow(window_height);
		
		/** add fourmi and show gui */
		terrain.addFourmi(myFourmi);
		terrain.show();
		
		
		
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(new TimerTask() {
            @Override
            public void run() {
                myFourmi.nextGeneration();
                terrain.update();
            }
        }, 0, 1);
	}

}
